/**
 * 
 */
package org.hotpotmaterial.code.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author wenxing
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "auto_release")
@Entity
@EntityListeners(value = {AuditingEntityListener.class})
public class AutoReleasePO extends BaseEntity {
  

  /**
   * serialVersionUID
   */
  private static final long serialVersionUID = -4919985061945552144L;

  /**
   * 项目id
   */
  @Column(name = "project_id")
  @JsonProperty("projectId")
  private String projectId;
  
  /**
   * 0.后台 1.前台
   */
  @Column(name = "platform")
  @JsonProperty("platform")
  private String platform;
  
  /**
   * 环境 0.测试 1.开发 
   */
  @Column(name = "env")
  @JsonProperty("env")
  private String env;
  
  /**
   * 是否k8s
   */
  @Column(name = "is_k8s")
  @JsonProperty("isk8s")
  private String isK8s;
  
  /**
   * 镜像名称
   */
  @Column(name = "image_name")
  @JsonProperty("imageName")
  private String imageName;
  
  /**
   * 容器名称
   */
  @Column(name = "name")
  @JsonProperty("name")
  private String name;
  
  @Transient
  @JsonProperty("ipList")
  @JsonPropertyDescription("发布机器ip")
  private List<ContainerIpPO> ipList;
  
  @Transient
  @JsonProperty("envList")
  @JsonPropertyDescription("运行参数")
  private List<ContainerEnvPO> envList;
  
  @Transient
  @JsonProperty("volumeList")
  @JsonPropertyDescription("挂载")
  private List<ContainerVolumePO> volumeList;
  
  /**
   * 更新属性
   * 
   * @param apiBasePO
   * @return
   */
  public AutoReleasePO updateAttrs(AutoReleasePO autoRelease) {
    this.name = autoRelease.getName();
    this.projectId = autoRelease.getProjectId();
    this.platform = autoRelease.getPlatform();
    this.env = autoRelease.getEnv();
    this.imageName = autoRelease.getImageName();
    this.isK8s = autoRelease.getIsK8s();
    return this;
  }
}
